home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
QUIZGAM.DIR
/
00178_Script_INITIALIZE HANDLERS
< prev
next >
Wrap
Text File
|
1996-03-19
|
7KB
|
219 lines
-- -----------------------------------------------------------------------------
-- handler startMovie
on startMovie
global spriteNrOfFirstTileOffset,spriteNrOfLastTile
setAuxiliarySearch
setSpritesVisibility (spriteNrOfFirstTileOffset + 1),spriteNrOfLastTile,TRUE
end
-- -----------------------------------------------------------------------------
-- handler stopMovie
on stopMovie
global spriteNrOfFirstTileOffset,spriteNrOfLastTile
setSpritesVisibility (spriteNrOfFirstTileOffset + 1),spriteNrOfLastTile,TRUE
showBackgroundTiles
end
-- -----------------------------------------------------------------------------
-- handler initializeLeoGame
on initializeLeoGame
global nrOfQuestionsPerTile,nrOfTiles,spriteNrOfFirstTileOffset,spriteNrOfLastTile
global questionIndex,waitFeedback,wrongAnswer,gameOverSound
global gameNr,QCastName,ACastName,answers,soundFolder,buttonHeight
global backgroundTileOffset,coloredTileOffset,soundHolder,feedBackSprite
-- 1 VARIABLE INITIALIZING
-- set the number of questions per tile,number of tiles
set nrOfQuestionsPerTile = 3
set backgroundTileOffset = 29
set nrOfTiles = 9
set coloredTileOffset = 1
set spriteNrOfFirstTileOffset = 10
set spriteNrOfLastTile = spriteNrOfFirstTileOffset + (2 * nrOfTiles)
set feedBackSprite = 29
-- IMPORTANT for handler showNextQuestionForTile
-- names of soundfiles
set wrongAnswer = "Wrong.aif"
set soundHolder = "soundHolder"
-- the name of the soundfolder...
set soundFolder = the pathName & "quizGamA"
-- need to know this in handler "getAnswerClicked"
set buttonHeight = the height of cast "oneButton"
-- contains correct answers for questions
set answers = field "answers"
-- name of castmembers with question,answer
set QCastName = "Q"
set ACastName = "A"
-- the position of the pointer to the next question in field questionNumbers
set questionIndex = nrOfQuestionsPerTile + 1
-- indicates the nr of the game we're starting with
set gameNr = 1
-- 2 HANDLERCALLS
-- make the background picture tiles invisible
hideBackgroundTiles
-- set the puppets of Q & A sprites AND the sprites containing coloredTiles
setQuestionPuppets TRUE
setColoredTilePuppets TRUE
-- set the stretch of the sprites containing coloredTiles to false
setQuestionStretch FALSE
setColoredTileStretch FALSE
end
-- -----------------------------------------------------------------------------
-- handler setQuestionPuppets sets the puppets of sprites containing Q and A
on setQuestionPuppets state
global spriteNrOfFirstTileOffset,spriteNrOfLastTile
setPuppets(spriteNrOfFirstTileOffset + 1),spriteNrOfLastTile,state
end
-- -----------------------------------------------------------------------------
-- handler setColoredTilePuppets sets the puppets of sprites containing colored tiles
on setColoredTilePuppets state
global coloredTileOffset,nrOfTiles
setPuppets (coloredTileOffset + 1),(coloredTileOffset + nrOfTiles),state
end
-- -----------------------------------------------------------------------------
-- handler setQuestionStretch sets the stretch of sprites containing Q and A
on setQuestionStretch state
global spriteNrOfFirstTileOffset,spriteNrOfLastTile
setStretch (spriteNrOfFirstTileOffset + 1),spriteNrOfLastTile,state
end
-- -----------------------------------------------------------------------------
-- handler setColoredTileStretch sets the stretch of sprites containing colored tiles
on setColoredTileStretch state
global coloredTileOffset,nrOfTiles
setStretch (coloredTileOffset + 1),(coloredTileOffset + nrOfTiles),state
end
-- -----------------------------------------------------------------------------
-- handler hideBackgroundTiles hides the tiled picture that gets revealed by answering
-- questions
on hideBackgroundTiles
global backgroundTileOffset,nrOfTiles
set firstSprite = (backgroundTileOffset + 1)
set lastSprite = (backgroundTileOffset + nrOfTiles)
repeat with currSprite = firstSprite to lastSprite
setSpriteVisibility currSprite FALSE
end repeat
end
-- -----------------------------------------------------------------------------
-- handler showBackgroundTiles hides the tiled picture that gets revealed by answering
-- questions
on showBackgroundTiles
global backgroundTileOffset,nrOfTiles
set firstSprite = (backgroundTileOffset + 1)
set lastSprite = (backgroundTileOffset + nrOfTiles)
repeat with currSprite = firstSprite to lastSprite
setSpriteVisibility currSprite TRUE
end repeat
end
-- -----------------------------------------------------------------------------
-- handler makeRandomQuestionOrder creates nrOfTiles lines with nrOfQuestionsPerTile
-- random unique numbers
on makeRandomQuestionOrder
global nrOfQuestionsPerTile,nrOfTiles,questionNumbers,answers,questionIndex
global spriteNrOfFirstTileOffset
-- determine which questions we need for game gameNr
set firstQuestionNr = getStartNr()
set lastQuestionNr = getEndNr()
set nrOfQuestions = nrOfQuestionsPerTile * nrOfTiles
set sourceList = getSourceList(firstQuestionNr,lastQuestionNr)
-- empty the field that contains random questionnumbers
put "" into field "questionNumbers"
repeat with tile = 1 to nrOfTiles
set tileQuestions = []
set nrOfDraws = 0
repeat with question = 1 to nrOfQuestionsPerTile
-- pick a random index used to draw a question
set nrOfQuestionsUsed = ((tile - 1) * nrOfQuestionsPerTile) + nrOfDraws
set index = random(nrOfQuestions - nrOfQuestionsUsed)
-- draw the question number from the ordered list
set aQuestion = getAt(sourceList,index)
-- add the drawn question to a string, separated by the itemdelimiter
append(tileQuestions,aQuestion)
-- delete the randomly picked item so we don't draw it twice
deleteAt (sourceList,index)
set nrOfDraws = nrOfDraws + 1
end repeat
-- add the pointer to the first question to be asked to the line of questionnumbers
append(tileQuestions,1)
-- add the questions for this tile to the field
putListIntoLineOfField tileQuestions,tile,"questionNumbers"
end repeat
-- read the field with questionnumbers into a variable
set questionNumbers = field "questionNumbers"
-- fill each tile on screen with a question and answers
repeat with currTile = 1 to nrOfTiles
set qSprite = 2 * currTile + spriteNrOfFirstTileOffset - 1
set aSprite = 2 * currTile + spriteNrOfFirstTileOffset
getQuestionForTile currTile,qSprite,aSprite
end repeat
end